//
//  ScoreTableViewCell.m
//  iBaby365v2
//
//  Created by Kirinrin on 14-7-17.
//  Copyright (c) 2014年 suplus. All rights reserved.
//

#import "ScoreTableViewCell.h"

@implementation ScoreTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)awakeFromNib
{
    // Initialization code
    self.message.delegate = self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)scoreOptionValueChanged:(UISegmentedControl *)sender {
    NSLog("scoreOptionValueChanged");
    switch (sender.tag) {
        case 100:
        {
            switch (sender.selectedSegmentIndex) {
                case 0:
                    self.childData.option0 = 1;
                    break;
                case 1:
                    self.childData.option0 = 2;
                    break;
                case 2:
                    self.childData.option0 = 3;
                    break;
                default:
                    break;
            }
        }
            break;
        case 101:
            switch (sender.selectedSegmentIndex) {
                case 0:
                    self.childData.option1 = 1;
                    break;
                case 1:
                    self.childData.option1 = 2;
                    break;
                case 2:
                    self.childData.option1 = 3;
                    break;
                default:
                    break;
            }
            break;
        case 102:
            switch (sender.selectedSegmentIndex) {
                case 0:
                    self.childData.option2 = 1;
                    break;
                case 1:
                    self.childData.option2 = 2;
                    break;
                case 2:
                    self.childData.option2 = 3;
                    break;
                default:
                    break;
            }
            break;
        case 103:
            switch (sender.selectedSegmentIndex) {
                case 0:
                    self.childData.option3 = 1;
                    break;
                case 1:
                    self.childData.option3 = 2;
                    break;
                case 2:
                    self.childData.option3 = 3;
                    break;
                default:
                    break;
            }
            break;

    }
}

-(void)textFieldDidEndEditing:(UITextField *)textField{
    NSLog(@"textFieldDidEndEditing");
    self.childData.memo = textField.text;
}

-(void)setChildData:(ChildInfo *)childData{
    _childData = childData;
    [self.message setText:childData.memo];
    [self.option0 setSelectedSegmentIndex:childData.option0-1];
    [self.option1 setSelectedSegmentIndex:childData.option1-1];
    [self.option2 setSelectedSegmentIndex:childData.option2-1];
    [self.option3 setSelectedSegmentIndex:childData.option3-1];
}
@end
